﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Cognifide.PowerShell.Shell.Host;

using Sitecore.Data.Items;

namespace Cognifide.PowerShell.Tasks
{
    class ExecuteScriptTask
    {
        public void Update(Item[] items, Sitecore.Tasks.CommandItem command, Sitecore.Tasks.ScheduleItem schedule)
        {
            ScriptSession session = new ScriptSession();
            foreach (var item in items)
            {
                string script = item["Script"];
                if (!String.IsNullOrEmpty(script))
                {
                    session.ExecuteScriptPart(script);
                }
            }
        }
    }
}
